package org.nf.servlet;

import org.nf.demo.entity.Student;
import org.nf.demo.entity.StudentCc;
import org.nf.entity.StudentDd;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.http.HttpClient;

/**
 * @Author czl
 * @Date 2024-04-24
 */

@WebServlet("/showAll")
public class ShowStudentAllServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 思考：这里的 Student 对象是哪个工程的？
        Student stu = new Student("张三","男",18) ;

        StudentCc stuCc = new StudentCc();
        StudentDd stuDd = new StudentDd();

        String str1 = stuCc.showInfo(stu);
        String str2 = stuDd.showInfo(stu);

        req.setAttribute("stu1",str1);
        req.setAttribute("stu2",str2);

        // 转发页面
        req.getRequestDispatcher("showinfoAll.jsp").forward(req,resp);
    }
}
